Skip to content

feat(deploy): slice 2 — unit rendering, dry-run plans, generation log, status/rollback logic (#5766) - #7692

Merged
dezren39 merged 1 commit into
mainfrom
queue/13021-5766-deploy-dry-run
Nov 8, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/13021-5766-deploy-dry-run

Conversation

@developing-today

@developing-today developing-today Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Slice 2 of issue #5766 (deploy tool v1), building on slice 1 (PR #6231, merged: deployTargets registry + deploy list + definition validation). Queue task 13021.

What lands in pkgs/deploy/deploy.py:

  • Systemd unit rendering (render_unit) and a launchd plist stub (render_plist) from a registry definition. The rendered ExecStart / program path points at the service's per-service nix profile current link (/nix/var/nix/profiles/per-service/<name>/current/<entryPoint>, design §4.1) — never at a bare store path — so a generation flip is a profile repoint and the rendered file is identical for every generation of the same definition. systemd argument/environment quoting escapes whitespace, quotes, backslashes, and doubles the %/$ introducers.
  • deploy <target> --dry-run: the ordered §4.1 activation plan (build → install next generation into the profile → write unit/plist → daemon-reload → restart only that unit → health check → flip back on failure → append to the generation log), with no side effects.
  • Generation log (design §4.6): append-only JSONL per target under the state dir (--state-dir / $DEPLOY_STATE_DIR), one record per activation event carrying generation id, source rev, artifact, timestamp, actor, action, result. Logs are never truncated (two generations always retained).
  • deploy <target> status: folds the log into current/previous generations (a rollback event makes the generation it repointed to current) and reports the health verdict for the target's healthCheck URL, or that no check is defined.
  • rollback command logic: selects the previous distinct generation (repointing, never rebuilding) and is refused when fewer than two distinct generations were ever current.
  • Real activation — nix-env profile install, systemctl restart, health-check flip-back — is the next slice: the non-dry-run deploy/rollback paths say so explicitly and exit non-zero rather than pretending to have activated something. The remaining on-laptop E2E acceptance from issue deploy tool v1: target registry (deployTargets) + systemd generation activation #5766 also stays open there.

Tests

  • New pkgs/deploy/test_deploy_slice2.py (21 tests, stdlib unittest): unit/plist rendering invariants, generation-log round-trip/fold/rollback-fold, plan ordering and flip-back step, rollback refusal cases, status formatting, and CLI subprocess cases (dry-run creates no state, real deploy refused, seeded-log status, unknown target). Oracle: design §4.1/§4.2/§4.6 + the issue text, named in the test module docstring.
  • New flake check deploy-slice2-tests in lib/default.nix next to deploy-dupkeys-property, running the new test file against deploy.py in CI.
  • Existing coverage re-verified locally on the laptop against the new deploy.py: test_dupkeys_property.py (300 cases, property holds), deploy list on a valid registry, malformed registry rejected with field-level errors, status on an empty log.

Refs #5766 (issue stays open for the activation slice + E2E acceptance).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@developing-today
developing-today Bot requested review from a team and dezren39 as code owners November 8, 2026 13:08
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc92e39b-1c4c-4165-9d35-537646d3c496

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant